package view;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import model.Model;
import model.entity.BasicEntity;
import model.map.World;
import model.skill.ActivateableSkill;
import model.skill.Skill;

public class SkillsListProvider extends ListProvider {
	private BasicEntity bc;
	/**
	 * The SkillsListProvider constructor takes in a BasicEntity to observer using the observer pattern.  
	 */
	public SkillsListProvider(BasicEntity bc ) {
		setListOverlayList(new ArrayList<ListOverlay>());
		setModelsList(new ArrayList<Model>());
		setListenerMap(new HashMap<Model, MouseListener>());
		this.setBc(bc);
		bc.register(this);
		this.update(bc);
	}

	@Override
	public void update(Model m) {
		List<ActivateableSkill> skillsList = World.getInstance().getPlayer().getOccupation().getCurrentActivateableSkills();
		for(ActivateableSkill s : skillsList) {
			final Skill skill = s;
			getModelsList().add(s);
			getListenersMap().put(s, new MouseListener() {

				@Override
				public void mouseClicked(MouseEvent e) {
					// TODO Implement Skill
					System.out.println("You clicked on " + skill.getName());
				
				}

				@Override
				public void mouseEntered(MouseEvent e) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void mouseExited(MouseEvent e) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void mousePressed(MouseEvent e) {
					// TODO Auto-generated method stub
					
				}

				@Override
				public void mouseReleased(MouseEvent e) {
					// TODO Auto-generated method stub
					
				}
				
			});
		}
	}

	/**
	 * @param bc the bc to set
	 */
	public void setBc(BasicEntity bc) {
		this.bc = bc;
	}

	/**
	 * @return the bc
	 */
	public BasicEntity getBc() {
		return bc;
	}
}
